package com.example.user3.demo;

import android.app.ProgressDialog;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.example.user3.demo.contract.MainContract;
import com.example.user3.demo.mvp.presenter.MainPresenter;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.zzy.base.activity.BaseActivity;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;


public class RecyclerViewActivity extends BaseActivity<MainContract.IPresenter> implements MainContract.IView {
//    Adapter2 adapterVerticalMain;
    RecyclerView recycler_vertical;

    List<CityHomeBean> mDataList;;
    StaggeredGridLayoutManager gridLayoutManager;
    RecyclerViewActivity recyclerViewActivity;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);



    }

    @Override
    protected MainContract.IPresenter setPresenter() {
        return new MainPresenter() ;
    }
    @Override
    protected void initData() {
        gridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
        gridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
        recycler_vertical.setLayoutManager(gridLayoutManager);
        mDataList= new ArrayList<>();

//        String json =FileUtils.getJson("aab.txt",RecyclerViewActivity.this);
//        Type type =new TypeToken<List<CityHomeBean>>() {}.getType();
//        List<CityHomeBean>   S = new Gson().fromJson(json, type);
//        for(int i=0;i<S.size();i++) {
//            CityHomeBean cityHomeBean = S.get(i);
//            if(cityHomeBean.show_type== Adapter2.TYPE_VIDEO){
//                mDataList.add(cityHomeBean);
//            }
//        }
//        adapterVerticalMain = new Adapter2(RecyclerViewActivity.this,mDataList);
//        adapterVerticalMain.setHasStableIds(true);
//
//        recycler_vertical.setAdapter(adapterVerticalMain);
//        recycler_vertical.addOnScrollListener(new ImageAutoLoadScrollListener(gridLayoutManager));
    }

    @Override
    protected void initLayout(Bundle savedInstanceState) {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_recycler;
    }

    @Override
    protected void initViews() {

    }

    @Override
    protected void onResume() {
        super.onResume();


    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
    ProgressDialog dialog;
    @Override
    public void showLoading() {
        dialog = new ProgressDialog(this);
        dialog.show();
    }

    @Override
    public void hideLoading() {
        dialog.dismiss();
    }

    @Override
    public void success(String content){
    }


}
